import { createRouter, createWebHashHistory } from "vue-router";
import Home from "../views/Index.vue";
import ExamLayout from "../views/exam/ExamLayout.vue";

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/adminLogin",
    name: "AdminLogin",
    component: () => import("../views/admin/AdminLogin.vue"),
  },
  {
    path: "/exam/:examId(\\d+)",
    component: ExamLayout,
    children: [
      {
        path: "login",
        name: "LoginExam",
        component: () => import("../views/exam/LoginExam.vue"),
      },
      {
        path: "list",
        name: "ExamList",
        component: () => import("../views/exam/ExamList.vue"),
      },
      {
        path: "finish",
        name: "ExamFinish",
        component: () => import("../views/exam/ExamFinish.vue"),
      },
      {
        path: "result",
        name: "ViewResult",
        component: () => import("../views/exam/ViewResult.vue"),
      },
    ],
  },
  {
    path: "/admin",
    component: () => import("../views/admin/AdminLayout.vue"),
    children: [
      {
        path: "index",
        name: "AdminIndex",
        component: () => import("../views/admin/AdminIndex.vue"),
      },
      {
        path: "examManage",
        name: "ExamManage",
        component: () => import("../views/admin/ExamManage.vue"),
      },
      {
        path: "paperManage",
        name: "PaperManage",
        component: () => import("../views/admin/PaperManage.vue"),
      },
      {
        path: "userManage",
        name: "UserManage",
        component: () => import("../views/admin/UserManage.vue"),
      },
      {
        path: "adminManage",
        name: "AdminManage",
        component: () => import("../views/admin/AdminManage.vue"),
      },
      {
        path: "questionManage/:paperId",
        name: "QuestionManage",
        component: () => import("../views/admin/QuestionManage.vue"),
      },
      {
        path: "examStatus/:examId",
        name: "ExamStatus",
        component: () => import("../views/admin/ExamStatus.vue"),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
